using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FishNet.Object;

public class BulletController : MonoBehaviour
{
    private Vector3 _direction;
    private float _passedTime;
    public float Speed = 5f;

    // Update is called once per frame
    private void Update()
    {
        //if (IsServer)
        //{
        //    _direction = transform.forward;
        //    Move();
        //}

        Move();
    }

    private void Move()
    {
        float delta = Time.deltaTime;

        float passedTimeDelta = 0f;
        if (_passedTime > 0f)
        {
            float step = (_passedTime * 0.08f);
            _passedTime -= step;

            if (_passedTime <= (delta / 2f))
            {
                step += _passedTime;
                _passedTime = 0f;
            }
            passedTimeDelta = step;
        }
        transform.Translate(_direction * Speed * (Time.deltaTime + passedTimeDelta));
    }

    internal void Initialize(Vector3 direction, float passedTime)
    {
        _direction = direction;
        _passedTime = passedTime;
    }
}